package com.gitee.mars.studyabroad.controller;

import com.gitee.mars.studyabroad.request.UserCollectAbroadSchoolRequest;
import com.gitee.mars.studyabroad.response.result.R;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

import java.util.Arrays;

import com.gitee.mars.studyabroad.entity.UserCollectAbroadSchool;
import com.gitee.mars.studyabroad.service.IUserCollectAbroadSchoolService;

/**
 * UserCollectAbroadSchool 控制层
 *
 * @Author wq
 * @Date 2021-04-22
 **/
@RestController
@RequestMapping("/userCollectAbroadSchool")
@AllArgsConstructor
public class UserCollectAbroadSchoolController {

    private final IUserCollectAbroadSchoolService userCollectAbroadSchoolService;

    /**
     * 收藏或者取消
     *
     * @param request request
     * @return R
     */
    @PostMapping("/addOrCancel")
    public R addOrCancel(@RequestBody UserCollectAbroadSchoolRequest request) {
        userCollectAbroadSchoolService.addOrCancel(request);
        return R.success();
    }

    /**
     * 收藏列表
     *
     * @param userId 用户ID
     * @return R
     */
    @GetMapping("/collectList")
    public R collectList(Integer userId) {
        return R.success(userCollectAbroadSchoolService.collectList(userId));
    }

}